from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

class BasePage:
    def __init__(self, driver):
        self.driver = driver

    def find_element(self, locator, time=10):
        return WebDriverWait(self.driver, time).until(EC.presence_of_element_located(locator))

    def click_element(self, locator, time=10):
        element = self.find_element(locator, time)
        element.click()

    def enter_text(self, locator, text, time=10):
        element = self.find_element(locator, time)
        element.click()
        element.clear()
        element.send_keys(text)

    def cd_iframe(self, locator):
        element = self.find_element(locator)
        self.driver.switch_to.frame(element)